<?php

class Application_Model_DbTable_Regnumbers extends Zend_Db_Table_Abstract
{

    protected $_name = 'regnumbers';

    protected $_referenceMap = array(
        "users"=>array(
            'columns' => array("users"),
            'refTableClass' => "Application_Model_DbTable_Users",
            'refColumns'=> array("idUsers")
    ));
    
    
    public function UpdateStatus(Zend_Date $date) {
        $strDate = $date->toString("yyyy-MM-dd");
        $dbResult = new Application_Model_DbTable_Result();
        $listNum = $this->fetchAll($this->select()->where("	DateRegistry LIKE ?", $strDate));
        $books = $dbResult->fetchAll($dbResult->select()->where("DateOut LIKE ?", $strDate))->toArray();
        
        foreach($listNum as $num) {
            $books_temp = $books;
            if($num->Channel != 0) {
                if($num->Channel == 2) {
                    unset($books_temp[0]);
                }
                if($num->Channel == 1) {
                    unset($books_temp[1]);
                }
            }
            $tien_trung = 0;
            foreach($books_temp as $book) {
                if($num->TypeRegistry==0) {
                    
                    
                    // Nếu có bao lô                    
                    if(!$num->BPrice) {
                        
                    }
                    // Nếu có đánh đầu
                    if(!$num->FPrice) {
                        
                    }
                    // Nếu có đánh đuôi
                    if(!$num->LPrice) {
                        
                    }
                }else{
                    
                }
            }            
        }
    }    
}

